package com.whcoding.test.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author whcoding
 * @version 1.0.0
 * @ClassName CarNumEnums
 * @Description 车牌号前缀和省对应的枚举
 * @Date 2020/7/23 10:24
 */
@Getter
@AllArgsConstructor
public enum CarNumEnums {

    HE_BEI("冀", "河北", "114.30,38.02"),

    NEI_MENG_GU("蒙", "内蒙古", "111.41,40.48"),

    JI_LIN("吉", "吉林", "125.19,43.54"),

    SHANG_HAI("沪", "上海", "121.29,31.14"),

    AN_HUI("皖", "安徽", "117.17,bai31.52"),

    SHAN_DONG("鲁", "山东", "117.00,36.40 "),

    HU_BEI("鄂", "湖北", "114.17,30.35 "),

    GUANG_XI("桂", "广西", "108.19,22.48 "),

    CHONG_QING("渝", "重庆", "106.33,29.35"),

    XI_ZANG("藏", "西藏", "91.08,29.39"),

    GAN_SU("甘", "甘肃", "103.51,36.04"),

    XIN_JIANG("新", "新疆", "87.36,43.45"),

    NING_XIA("宁", "宁夏", "106.16,38.27"),

    QING_HAI("青", "青海", "101.48,36.38"),

    SHAAN_XI("陕", "陕西", "108.57,34.17"),

    GUI_ZHOU("贵", "贵州", "106.42,26.35"),

    SI_CHUAN("川", "四川", "104.04,30.40"),

    HAI_NAN("琼", "海南", "110.20,20.02"),

    GUANG_DONG("粤", "广东", "113.14,23.08"),

    HU_NAN("湘", "湖南", "112.59,28.12"),

    YUN_NAN("云", "云南", "102.42,25.04"),

    HE_NAN("豫", "河南", "113.40,34.46 "),

    JIANG_XI("赣", "江西", "115.55,28.40"),

    FU_JIAN("闽", "福建", "119.18,26.05"),

    ZHE_JIANG("浙", "浙江", "120.10,30.16"),

    JIANG_SU("苏", "江苏", "118.46,32.03"),

    HEI_LONG_JIANG("黑", "黑龙江", "126.36,45.44"),

    LIAO_NING("辽", "辽宁", "123.25,41.48"),

    SHAN_XI("晋", "山西", "112.33,37.54"),

    BEI_JIN("京", "北京", "116.20,39.56"),

    TIAN_JIN("津", "天津", "117.20,39.12"),

    OTHER("other", "其他", "0,0");
    /**
     * 车牌号前缀
     */
    private String carNum;
    /**
     * 省级行政单位名次
     */
    private String prov;

    /**
     * 所在省对应的省会坐标
     */
    private String pos;

    public static CarNumEnums getEnums(String carNum) {
        return Stream.of(values())
                .filter(enums -> enums.carNum.equals(carNum))
                .findFirst()
                .orElse(CarNumEnums.OTHER);
    }

    public static CarNumEnums getEnumsByAddress(String address) {
        return Stream.of(values())
                .filter(enums -> address.startsWith(enums.getProv()))
                .findFirst()
                .orElse(CarNumEnums.OTHER);
    }

}